package com.chinasoft.mall.activity.adapter;

import java.util.List;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.chinasoft.mall.R;
import com.chinasoft.mall.activity.MainActivity;
import com.chinasoft.mall.model.response.EpgBean;
import com.chinasoft.mall.util.StringUtil;
import com.chinasoft.mall.widget.NetImageView;

public class GallaryImplAdapter extends BaseAdapter{
	private LayoutInflater inflater;
	private ViewHolder _vh;
	private List<EpgBean> rbs;
	
	public GallaryImplAdapter(MainActivity activity,List<EpgBean> rbs) {
		inflater = LayoutInflater.from(activity);
		this.rbs=rbs;
	}
	
	public void setData(List<EpgBean> rbs){
			this.rbs=rbs;
			this.notifyDataSetChanged();
	}
	
	public List<EpgBean> getData(){
		return rbs;
	}
	
	@Override
	public int getCount() {
		if (rbs == null) {
			return 0;
		} else {
			return rbs.size();
		}
	}

	@Override
	public Object getItem(int position) {
		if (rbs == null) {
			return null;
		} else {
			return rbs.get(position);
		}
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.imagegv, null);
			_vh = new ViewHolder();
			_vh.netimage = (NetImageView) convertView.findViewById(R.id.netimage);
			convertView.setTag(_vh);
		} else {
			_vh = (ViewHolder) convertView.getTag();
		}
		EpgBean rb=rbs.get(position);
		_vh.netimage.setDownload(StringUtil.shopUrl(rb.getGOODS_ID(),rb.getFOCUS()));
		return convertView;
	}
	/**
	 * 跳转到详情
	 * 
	 * @author Administrator
	 * 
	 */
	class onClickImpl implements View.OnClickListener {
		private EpgBean rb;

		public onClickImpl(EpgBean rb) {
			this.rb = rb;
		}

		@Override
		public void onClick(View v) {
			if (rb != null) {
//				activity.setCurrentActivity(SpDetailActivity.class, rb);
			}
		}
	}
	
	class ViewHolder {
		public NetImageView netimage;
	}
}
